import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const Login = () => import('@/views/login')
const ForgetPassword = () => import('@/views/forgetPassword/forgetPassword')
const EditPassword = () => import('@/views/editPassword/editPassword')
const My = () => import('@/views/my/index')
const AccountSettings = () => import('@/views/accountSettings/accountSettings')
const UserCenter = () => import('@/views/userCenter/userCenter')
const Commission = () => import('@/views/my/commission')
const CommissionDetail = () => import('@/views/my/commissionDetail')
const ErCode = () => import('@/views/my/erCode')
const MyStore = () => import('@/views/my/myStore')



export default new Router({
  mode: 'history',
  routes: [{
      path: '/',
      name: 'login',
      component: Login,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '登录'
      }
    },
    {
      path: '/forgetPassword',
      name: 'forgetPassword',
      component: ForgetPassword,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '忘记密码'
      }
    },
    {
      path: '/editPassword',
      name: 'editPassword',
      component: EditPassword,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '修改密码'
      }
    },
    {
      path: '/my',
      name: 'my',
      component: My,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '我的'
      }
    },
    {
      path: '/accountSettings',
      name: 'accountSettings',
      component: AccountSettings,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '账号设置'
      }
    },
    {
      path: '/userCenter',
      name: 'userCenter',
      component: UserCenter,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '商家中心'
      }
    },
    {
      path: '/commission',
      name: 'commission',
      component: Commission,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '我的佣金'
      }
    },
    {
      path: '/commissionDetail',
      name: 'CommissionDetail',
      component: CommissionDetail,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '我的佣金详情'
      }
    },
    {
      path: '/erCode',
      name: 'ErCode',
      component: ErCode,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '我的二维码'
      }
    },
    {
      path: '/myStore',
      name: 'MyStore',
      component: MyStore,
      meta: {
        requireAuth: false,
        showMainHeader: true,
        showMainFooter: true,
        title: '我的门店'
      }
    },
    {
      path: '*', // 路由重定向
      redirect: '/'
    }
  ],
  // 控制页面跳转时位置
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  }
})
